package contegor.scire.core;

import java.io.Serializable;

/**
 * Interface for all executable tasks in a concept cloud.
 *
 * @version $Revision: 1.2 $
 * @author  Héctor Cirbián Pousa ($Author: hector $)
 */
@Version("$Id: Task.java,v 1.2 2010-02-01 10:55:40 hector Exp $")
public interface Task<R> extends Serializable {

  /** Sets the {@link TaskId} */
  public void setTaskId(TaskId taskId);

  /** Returns the {@link TaskId} */
  public TaskId getTaskId();

  /** Returns the {@link Id} of the {@link Container} target of the task. */
  public Id getTargetContainerId();

  /** Called when the task processing starts. */
  public void start(Container targetContainer, ReturnPoint<? super R> returnPoint);
  
  /**
   * Does the effective processing of the task. This processing will be done inside the {@link Container} target
   * of the task.
   *   
   * @param targetContainer {@link Container} required by the {@link #getTargetContainerId()} and inside.
   * @throws ScireException if the processing can't be accomplished.
   */
  public void process(Container targetContainer) throws ScireException;

  /** Called when the task ends. */
  public void finish();
}
